#!/bin/bash
mysql -u root -p <<EOF
drop database nova;
drop database keystone;
drop database cinder;
drop database glance;
drop database dash;
create database nova;
create database keystone;
create database cinder;
create database glance;
create database dash;
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'127.0.0.1' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'127.0.0.1' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'127.0.0.1' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'127.0.0.1' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON dash.* TO 'dash'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON dash.* TO 'dash'@'127.0.0.1' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON dash.* TO 'dash'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EOF

#echo "keystone db sync"
#keystone-manage db_sync
#echo "glance db sync"
#glance-manage db_sync
#echo "nova db sync"
#nova-manage db sync
#echo "cinder db sync"
#cinder-manage db sync
